package com.haixiaoke.saas.repository.service.impl;

import com.haixiaoke.saas.repository.dto.HousingAllocationDTO;
import com.haixiaoke.saas.repository.mapper.HouseMapper;
import com.haixiaoke.saas.repository.pojo.House;
import com.haixiaoke.saas.repository.service.IHouseService;
import com.haixiaoke.saas.repository.vo.HousingAllocationVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;

/**
 * 房屋业务层处理
 *
 * @author haixiaoke
 * @date 2023-04-10
 */
@Service
public class HouseServiceImpl implements IHouseService {
    @Autowired
    private HouseMapper houseMapper;

    /**
     * 查询房屋表saas_house
     *
     * @param id 房屋表saas_house主键
     * @return 房屋表saas_house
     */
    @Override
    public House selectHouseById(String id) {
        return houseMapper.selectHouseById(id);
    }

    /**
     * 查询房屋表saas_house列表
     *
     * @param house 房屋表saas_house
     * @return 房屋表saas_house
     */
    @Override
    public List<HousingAllocationVO> selectHouseList(HousingAllocationDTO house) {
        return houseMapper.selectHouseList(house);
    }

    /**
     * 新增房屋表saas_house
     *
     * @param house 房屋表saas_house
     * @return 结果
     */
    @Override
    public int insertHouse(House house) {
        house.setCreateTime(new Date());
        return houseMapper.insertHouse(house);
    }

    /**
     * 修改房屋表saas_house
     *
     * @param house 房屋表saas_house
     * @return 结果
     */
    @Override
    public int updateHouse(House house) {
        return houseMapper.updateHouse(house);
    }

    /**
     * 批量删除房屋表saas_house
     *
     * @param ids 需要删除的房屋表saas_house主键
     * @return 结果
     */
    @Override
    public int deleteHouseByIds(String[] ids) {
        return houseMapper.deleteHouseByIds(ids);
    }

    /**
     * 删除房屋表saas_house信息
     *
     * @param id 房屋表saas_house主键
     * @return 结果
     */
    @Override
    public int deleteHouseById(String id) {
        return houseMapper.deleteHouseById(id);
    }

    @Override
    public HashMap<String, Integer> selectCount() {
        //返回”toDoGroundingNum“待上架、”groundingNum“上架、”undercarriageNum“下架
        return houseMapper.selectCount();
    }

    @Override
    public List<HousingAllocationVO> selectHouseListApplet(HousingAllocationDTO house) {
        return houseMapper.selectHouseListApplet(house);
    }

    @Override
    public List<String> getHousingInSameCommunity(String residenceCommunityId, String houseId) {
        return houseMapper.getHousingInSameCommunity(residenceCommunityId, houseId);
    }

    @Override
    public List<House> apartmentFilter(House house) {
        return houseMapper.apartmentFilter(house);
    }

    @Override
    public List<House> selectByHouseIds(List<String> houseId) {
        return houseMapper.selectByHouseIds(houseId);
    }
}
